<?php
class Invitecode extends BaseModel
{
    protected $res;
    protected $redis_key="admin_";
    public function getSource()
    {
        return "f_invitecode_shares";
    }

    public function invite_list($params=[]){
        if(isset($params['keywords']) && !empty($params['keywords'])){
            $condition = "title like '%{$params['keywords']}%'";
        }else{
            $condition = '';
        }
        $cate_list = $this::find(
            array(
                $condition,
                "order" => 'id desc',
            ));
        return $cate_list;
    }

    /**
     * @func 获取公告详情
     * @param $id
     * @return array
     */
    public function invite_detail($id){
        if(empty($id)){
            return [];
        }
        $cate_info = $this->findFirstById($id);
        if($cate_info){
            return $cate_info->toarray();
        }else{
            return [];
        }
    }

    public function invite_save($params){
        $result = $this::save($params);
        if($result){
            return true;
        }else{
            return false;
        }
    }

}
